package com.wits.qso.dao.impl;

import java.util.List;

import javax.persistence.EntityTransaction;
import javax.persistence.Query;

import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import com.wits.platform.dao.impl.BaseDaoImpl;
import com.wits.platform.entity.User;
import com.wits.platform.service.UserService;
import com.wits.qso.dao.custom.StudentDaoCustom;
import com.wits.qso.entity.Student;

@Component
public class StudentDaoImpl extends BaseDaoImpl<Student, String> implements StudentDaoCustom {

	@Override
	public List<User> getUser(String stuUserId) {
		String strSql = " select * from wits_user where user_id='"+stuUserId+"'";
		return em.createNativeQuery(strSql,User.class).getResultList();
	}

	@Override
	public List<Student> findByDiscussionGroupId(String groupId) {
		String sql="select stu.* from qso_student stu left join qso_discussion_member dm on(stu.stu_userid=dm.user_id)";
		sql+=" where dm.group_id=?";
		return this.findByNative(Student.class, sql,groupId);
	}

	@Override
	public List<String> findUserIdByClsId(String clsId) {
		String hql="select stuUserId from Student where clsId=:classId";
		return em.createQuery(hql).setParameter("classId", clsId).getResultList();
	}

}
